define(
	[],
	function() {
	
		return {
			create: function(creatorFunc, destructorFunc) {
				var _self		= null;
				var _deadObjs 	= [];
				
				function _init(idx) {
					_self.deadFlags[idx] = false;
					if(!_self.objects[idx]) {
						var obj = creatorFunc();
						obj.getId = function() { return idx; };
						_self.objects[idx] = obj;
					}
				}
			
				return _self = {
					objects		: [],
					deadFlags	: [],
					get: function() {
						//Get valid objects' index
						var idx;
						if(_deadObjs.length <= 0)
							idx = _self.objects.length;
						else
							idx = _deadObjs.pop();
							
						//reinit the object at the index and return it
						_init(idx);
						return _self.objects[idx];
					},
					let: function(obj) {
						var idx = obj.getId();
						destructorFunc(obj);
						_self.deadFlags[idx] = true;
						_deadObjs.push(idx);
					}
				}
			}
		}
	}
);